package com.e3.basdoc.goodscls.client;

import java.util.ArrayList;
import java.util.List;

import com.e3.basdoc.goodscls.model.GoodsClsModel;
import com.e3.basdoc.goodscls.model.GoodsClsQC;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.web.core.client.GwtAsyncCallback;
import com.e3.web.core.model.SuperQC;
import com.e3.web.widget.client.MyField;
import com.extjs.gxt.ui.client.widget.form.Field;

public class GoodsClsQueryDialog extends TGFQueryDialog<GoodsClsModel> {

	private GoodsClsRPCServiceAsync service = GoodsClsRPCService.Util.getInstance();

	@Override
	protected List<Field<?>> getFormFields() {
		String[] fNames = {GoodsClsModel.CODE,GoodsClsModel.NAME};
		List<Field<?>> fields = new ArrayList<Field<?>>(fNames.length);
		for (String fName : fNames) {
			Field<?> field = GoodsClsHelper.INSTANCE.createFormField(fName);
			fields.add(field);
		}
		return fields;
	}
	
	@Override
	protected SuperQC getQueryCondition() {
		MyField<?> field = getMyFormField(GoodsClsModel.CODE);
		String code = (String)field.getFieldValue();
		field = getMyFormField(GoodsClsModel.NAME);
		String name = (String)field.getFieldValue();
				
		final GoodsClsQC qc = new GoodsClsQC();
		qc.setCode(code);
		qc.setName(name);
		return qc;
	}

	@Override
	protected void executeQueryService(SuperQC qc,GwtAsyncCallback<List<GoodsClsModel>> callback) {
		service.getGoodsClsByCondition((GoodsClsQC)qc, getQueryAsyncCallBack(qc));
	}

}
